package com.itqf.controller;

import org.springframework.web.bind.annotation.ExceptionHandler;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * projectName: springmvc2103
 *
 * @author: 赵伟风
 * time: 2021/7/5 15:15
 * description:
 */
public class ErrorController {

    /**
     * 异常收集方式!
     * 单一的作用到某一个controller
     * [当前controller出现异常!会走此方法!]
     * @param re
     * @param request
     * @return
     */
    @ExceptionHandler
    public  Object  handleException(RuntimeException re, HttpServletRequest request)
    {

        Map<String,Object> map = new HashMap<>();
        map.put("code", 0);
        map.put("msg","您的网络异常!请稍后再试!");


        return map;
    }
}
